package com.yyaccp.appinfo.service;

import com.yyaccp.appinfo.domain.AppInfo;
import com.yyaccp.appinfo.domain.AppVersion;
import com.yyaccp.appinfo.domain.DevUser;
import com.yyaccp.appinfo.mapper.AppInfoMapper;
import com.yyaccp.appinfo.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("appInfoService")
public class AppInfoService {

    @Autowired
    private AppInfoMapper appInfoMapper;

    public void AppInfoPage(AppInfo appInfo, Page page){
        int totalCount = appInfoMapper.selectAppInfoCount(appInfo);
        page.setTotalCount(totalCount);
        List<AppInfo> appInfoList = appInfoMapper.selectAppInfoPage(appInfo,(page.getCurrPage()-1)*page.getPageSize(),page.getPageSize());
        page.setList(appInfoList);
    }

    public int updateStatusById(AppInfo appInfo){
        return appInfoMapper.updateStatusById(appInfo);
    }

    public int Add(AppInfo appInfo){
        return appInfoMapper.add(appInfo);
    }

    public AppInfo selectId(Long id){return appInfoMapper.selectByPrimaryKey(id);}

    public int update(AppInfo appInfo){
        return appInfoMapper.update(appInfo);
    }

    public int updateVersion(AppVersion appVersion){return appInfoMapper.updateVersion(appVersion);}

    public int deleteByPrimaryKey(Long appId){
        return appInfoMapper.deleteByPrimaryKey(appId);
    }

    public int onSale(Long id){
        return appInfoMapper.onSale(id);
    }

    public int offSale(Long id){
        return appInfoMapper.offSale(id);
    }

    public List<AppInfo> searchAll(){
        return appInfoMapper.selectAll();
    }
}
